package cn.hp.controller;

import cn.hp.entity.LoginInfor;
import cn.hp.service.ILoginInforService;
import cn.hp.util.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/loginInfor")
public class LoginInforController {
    @Autowired
    private ILoginInforService loginInforService;

    @RequestMapping("/find")
    @ResponseBody
    public Result find(LoginInfor obj) {
        List<LoginInfor> loginInfors = loginInforService.selectLoginInforList(obj);
        return Result.RowsSuccess(loginInfors, loginInfors.size());
    }

    /**
     * 条件+分页查询
     */
    @RequestMapping("/page")
    @ResponseBody
    public Result findPage(LoginInfor obj, @RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "limit", defaultValue = "10") Integer limit) {
        System.out.println(obj);
        PageInfo<LoginInfor> loginInforPageInfo = loginInforService.selectLoginInforList(obj, page, limit);
        return Result.RowsSuccess(loginInforPageInfo);
    }
}
